<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>零花钱数字生成器（小于30）</title>
    <style>
      body {
        font-family: Arial, sans-serif;
        display: flex;
        justify-content: center;
        align-items: center;
        height: 100vh;
        margin: 0;
        background-color: #f5f5f5;
      }
      .container {
        text-align: center;
        padding: 20px;
        background-color: white;
        border-radius: 10px;
        box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
      }
      #randomNumber {
        font-size: 24px;
        font-weight: bold;
        color: #2c3e50;
        margin: 20px 0;
      }
      button {
        padding: 10px 20px;
        background-color: #3498db;
        color: white;
        border: none;
        border-radius: 5px;
        cursor: pointer;
        font-size: 16px;
        transition: background-color 0.3s;
      }
      button:hover {
        background-color: #2980b9;
      }
    </style>
  </head>
  <body>
    <div class="container">
      <h1>零花钱</h1>
      <p>点击按钮生成一个小于30的随机整数</p>
      <div id="randomNumber">?</div>
      <button onclick="generateRandomNumber()">生成随机数</button>
    </div>

    <script>
      function generateRandomNumber() {
        // 生成0到29的随机整数
        const randomNum = Math.floor(Math.random() * 30);

        // 显示结果
        document.getElementById("randomNumber").textContent = randomNum;
      }

      // 页面加载时自动生成一个随机数
      window.onload = generateRandomNumber;
    </script>
  </body>
</html>
